Skip to main content

All Questions

Tagged with
0votes
1answer
157views

How to replace text in file - conditions and arithmetic required

I need a script to change content in some text files. This a bit beyond my limited bash skills. Maybe perl or python would be a better approach, I have no experience with either of these. I have a ...
jamitin's user avatar
7votes
2answers
7kviews

Is there a way to replace last occurrence of match using a shell variable substitution?

% x=abracadabra % echo ${x//a/o} obrocodobro Hmph... Is there a way to replace the last occurrence of a pattern using shell substitions (IOW, without rolling out sed, awk, perl, etc.)?
kjo's user avatar
  • 16.2k
0votes
1answer
465views

Replace a value in URL

I'm new to Linux world and need some help. I have two files : A token.txt file with a string something like this: xd2111Vf124FfmrfJ22fag And a playlist.m3u file with the following: EXTM3U EXTINF:-1,...
Kenthz's user avatar
-2votes
1answer
72views

Replacing rows from one file with rows from other file [closed]

I am thinking how can I replace a portion of a file -- let's say lines from m to n with lines from other file and do this in an nice manner. I however don't want to ...
Daia Alexandru's user avatar
2votes
1answer
66views

Replace parts of files

I'm quite new in the linux world. I've got a file containing Usernames and Passwords, for browser authentications. eg.: user:ioeuwz5rf (Password generated with "openssl passwd ABCXYZ") Now, I want ...
Manu_H's user avatar
-1votes
1answer
1kviews

How do i create a sed script to prompt the user to replace a number in a file? [duplicate]

I'm new in Unix, and I'm learning about sed command. I need to write a very small script for searching a number in a file and replacing it. I tried doing grep, and than deleting the specific phone ...
Sophia_T213's user avatar
0votes
2answers
137views

If filename has more than n characters, delete the last ones

I'm kinda new with the unix shell, and I don't seem to find the answer of my problem : I have a folder containing multiple files : a correct filename contains exactly 13 characters (numbers + letters ...
AdW's user avatar
0votes
1answer
345views

How can I replace a filename with .ear in a file-list using sed?

I have a file whose contents look like: /appl/as/var/spool/ears/mps/ear1.ear ... I want to replace the name of only ear1.ear with ear2.ear and I am using the below sed command, but with no luck: ...
amol singh's user avatar
-3votes
1answer
6kviews

How can i replace a specific string within a line inside a text file [duplicate]

$ cat text.txt my name is Steven my age is 10 i like dogs What command will be fitting so that echo "Kate" will replace Steven on text.txt?
Cathleen M's user avatar

close